﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SportsStore.Domain.Abstract;
using SportsStore.Domain.Entities;

namespace SportsStore.Domain.Concrete
{
    public class EFProductRepository : IProductRepository
    {
        private EfDbContext context = new EfDbContext();
        public IQueryable<Product> Products
        {
            get { return context.Products; }
        }


        public void SaveProduct(Product prod)
        {
            if (prod.ProductID == 0)
            {
                context.Products.Add(prod);
            }            
            context.SaveChanges();
        }

        public void DeleteProduct(Product prod)
        {
            context.Products.Remove(prod);
            context.SaveChanges();
        }
    }
}
